package zhongbo.java.air.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;
import zhongbo.java.air.dictionary.model.AirCraft;
import zhongbo.java.air.dictionary.service.impl.AirCraftServiceImpl;

/**
 * 说明：
 * 飞机基础信息操作的相关接口
 *
 * @author 钟波dellNotebook
 * @since 2025年03月31日 星期一 08:30:28
 */
@RestController
@RequestMapping("airCraft")
@Api(tags = "飞机信息接口")
public class AirCraftController {

    @Autowired
    private AirCraftServiceImpl airCraftService;

    @PostMapping("add")
    @ApiOperation("添加")
    ResultVo<AirCraft> add(@RequestBody AirCraft entity) {
        AirCraft airCraft = airCraftService.add(entity);
        return ResultVo.ok(airCraft);
    }

    @GetMapping("delete")
    @ApiOperation("删除")
    ResultVo<String> delete(String entityId) {
        String delete = airCraftService.delete(entityId);
        return ResultVo.ok(delete);
    }

    @PostMapping("edit")
    @ApiOperation("修改")
    ResultVo<AirCraft> edit(@RequestBody AirCraft edit) {
        AirCraft airCraft = airCraftService.edit(edit);
        return ResultVo.ok(airCraft);
    }

    @GetMapping("findOne")
    @ApiOperation("查询一条")
    ResultVo<AirCraft> findOne(String entityId) {
        AirCraft airCraft = airCraftService.findAirPort(entityId);
        return ResultVo.ok(airCraft);
    }

    @GetMapping("findPage")
    @ApiOperation("分页查询列表")
    ResultVo<PageVo<AirCraft>> findPage(Integer page, Integer pageSize
            , String keyword, String fields
            , String oderByField, Boolean orderByAsc) {
        PageVo<AirCraft> pageVo = airCraftService.pageVo(page, pageSize, keyword, fields, oderByField, orderByAsc);
        return ResultVo.ok(pageVo);
    }

}
